#ifndef CUSTOMPRINTER_H
#define CUSTOMPRINTER_H

#include <QDialog>

#define ShowPrintDialog(document, log) CustomPrinter(document).show(log)

namespace Ui {
class CustomPrinter;
}

class CustomPrinter : public QDialog
{
    Q_OBJECT

public:
    enum PageSize { A4, A5 };
    enum Orientation { Horizontal, Vertical };

    explicit CustomPrinter(const QString &document, const PageSize &pageSize = A4, const Orientation &orientation = Vertical);
    explicit CustomPrinter(const QWidget *window, const PageSize &pageSize = A5, const Orientation &orientation = Horizontal);
    ~CustomPrinter();

    int show(const QString &message);
    static void exportToPdf(const QPixmap picture, const QString &file, const PageSize &pageSize = A5, const Orientation &orientation = Horizontal);

protected:
    void paintEvent(QPaintEvent *event);

private slots:
    void on_btnCancelPrint_clicked();
    void on_btnConfirmPrint_clicked();
    void on_btnRefresh_clicked();
    void on_btnClose_clicked();
    void on_cbxPrinter_currentTextChanged(const QString &arg1);

private:
    void initWidget(const PageSize &pageSize, const Orientation &orientation);
    void refreshPrinters();

private:
    Ui::CustomPrinter *ui;
    QWidget *m_window;
    QString m_document;
    QString m_message;
    static QString m_defaultPrinter; // 全局共享打印机
};

#endif // CUSTOMPRINTER_H
